using System;
using System.Windows.Forms;

using SBPweb.Modules.Modularity;
using SBPweb.Modules.Smartparts;

namespace SBPweb.Contracts.Messaging
{

	#region Connection event handler delegates

	public delegate void ConnectionHandler(object sender);
	public delegate void ConnectionErrorHandler(object sender, string message);

	#endregion

	public interface IMessagingService : IService
	{

		#region Events

		/// <summary>
		/// Raises when the connection closed with the Directory server
		/// </summary>
		event ConnectionHandler OnDisconnect;
		/// <summary>
		/// Raises when the authentication finished succesfully
		/// </summary>
		event ConnectionHandler OnAutenticate;
		/// <summary>
		/// Raises when the authentication finished not succesfully
		/// </summary>
		event ConnectionHandler OnAuthenticationError;
		/// <summary>
		/// Raises when some mistakes happened
		/// </summary>
		event ConnectionErrorHandler OnWarning;
		/// <summary>
		/// Raises when an error happened
		/// </summary>
		event ConnectionErrorHandler OnError;

		#endregion

		#region Properties

		/// <summary>
		/// This is the original DirectoryService instance
		/// </summary>
		object ManagedDirectoryServiceObject
        {
            get;
        }

		/// <summary>
		/// Is the connection estabilished?
		/// </summary>
		bool IsConnected
		{
			get;
		}

		/// <summary>
		/// Name of the server
		/// </summary>
		string Server
		{
			get;
			set;
		}

		/// <summary>
		/// Name of the conference server
		/// </summary>
		string ConferenceServer
		{
			get;
			set;
		}

		/// <summary>
		/// Name of the pubsub server
		/// </summary>
		string PubsubServer
		{
			get;
			set;
		}

		/// <summary>
		/// Communication port of the server
		/// </summary>
		int Port
		{
			get;
			set;
		}

		/// <summary>
		/// A floating window for debug function
		/// </summary>
        ISmartpart DebugControl
        {
            get;
        }

		/// <summary>
		/// The user of the connection
		/// </summary>
        string UserName
        {
            get;
        }

		/// <summary>
		/// The JID of the connection
		/// </summary>
        string UserJid
        {
            get;
        }
		#endregion

		#region Methods

		/// <summary>
		/// Try to connect to the server
		/// </summary>
		/// <param name="user">name of the user (without the server)</param>
		/// <param name="password">password</param>
		void Connect(string user, string password);
		/// <summary>
		/// Close the connection with the server
		/// </summary>
		void Disconnect();
		/// <summary>
		/// Set the state of the directory (=send a presence)
		/// </summary>
		/// <param name="state"></param>
        void SetDirectoryState(string state);

		#endregion

	}
}
